#include "contourmainwindow.h"
#include "ui_contourmainwindow.h"

ContourMainWindow::ContourMainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::ContourMainWindow)
{
    ui->setupUi(this);
    iniUI();
}

ContourMainWindow::~ContourMainWindow()
{
    delete ui;
}

void ContourMainWindow::iniUI()
{
    fLabCurFile = new QLabel;
    fLabCurFile->setMinimumWidth(150);
    fLabCurFile->setText("当前切片：");
    ui->statusbar->addWidget(fLabCurFile);
}

void ContourMainWindow::initContourWidget(std::shared_ptr<STLReader> sp_stl_reader, const ContourInfo &contour_info)
{
    m_sp_stl_reader = sp_stl_reader;

    if(m_sp_contourWidget)
        m_sp_contourWidget->deleteLater();

    m_sp_contourWidget = std::make_shared<STLContourWidget>(sp_stl_reader, contour_info, this);

    setCentralWidget(m_sp_contourWidget.get());

    m_sp_contourWidget->show();
}

void ContourMainWindow::updateCurrentFileLabel(const qsizetype& cur_contour_indice, const qsizetype& total_contour_amount)
{
    fLabCurFile->setText(QString("切片轮廓: %1/%2").arg(cur_contour_indice).arg(total_contour_amount));
}
